<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head th:include="common_include :: commonHead('参数修改')"/>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <form class="form-horizontal m" id="form-params-edit" th:object="${params}">
                <input id="rowKey" name="rowKey"  type="hidden" th:field="*{rowKey}" />
                <div class="form-group">
                    <label class="col-sm-3 control-label">参数代码</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="paramCode" id="paramCode" th:field="*{paramCode}" readonly="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label ">参数名称</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="paramName" id="paramName" th:field="*{paramName}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label ">参数值</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="paramValue" id="paramValue" th:field="*{paramValue}" required="true"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">状态</label>
                    <div class="col-sm-8" th:with="dicts=${@dictCode.selectDictCodeByType('sys_normal_disable')}">
                        <div th:each="dict : ${dicts}" th:class="${dict['cssStyle']}">
                            <input type="radio" th:id="${dict['codeValue']}" name="paramStatus" th:value="${dict['codeValue']}"
                                   th:field="*{paramStatus}">
                            <label th:for="${dict['codeValue']}" th:text="${dict['codeText']}"></label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">模块名称</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="moduleName"  th:field="*{moduleName}">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div th:include="common_include :: commonFoot"/>
<script type="text/javascript">
    var prefix = ctx + "system/params"

    $("#form-params-edit").validate({
        rules: {
            paramValue: {
                required: true,
            },
            paramCode: {
                required: true,
                remote: {
                    url: prefix + "/checkParamsUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        rowKey: function () {
                            return $.trim($("#rowKey").val());
                        },
                        paramCode: function () {
                            return $.trim($("#paramCode").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return data == "0";
                    }
                }
            },
        },
        messages: {
            "paramCode": {
                remote: "该参数已经存在"
            }
        },
        submitHandler: function (form) {
            $.operate.save(prefix + "/edit", $('#form-params-edit').serialize());
        }
    });

    function submitClick() {
        if ($('#form-params-edit').valid()) {
            $('#form-params-edit').submit()
        }
    }
</script>
</body>
</html>
